package vivace.view;

import vivace.model.*;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;

import java.util.*;

import lib.Komponenter.CTable;

/**
 * A panel that contains a project. 
 */
public class ProjectPanel extends JSplitPane implements Observer {

    private Integer key;
    private Project model;
    private Controller controller;

    /**
     * @return The key of the project
     */
	public Integer getKey(){
    	return this.key;
    }

	/**
	 * Constructor
	 * @param key The key of the project
	 * @param model The model to use
	 */
    public ProjectPanel( Project model ) {
    	super(JSplitPane.HORIZONTAL_SPLIT);
    	// Assign the model and the controller 
    	this.model = model;
    	this.model.addObserver(this);
    	this.controller = new Controller(this);
   
    	// Create tracks frame
        TrackList tracks = new TrackList(model);
        TrackContent content = new TrackContent(model);
        
        this.setLeftComponent(tracks);
        this.setRightComponent(content);
        this.setContinuousLayout(true);
        this.setDividerLocation(400);

    }
        
    @Override
    public void update(Observable o, Object arg){
    	
    	// Check which type of action that was performed
    	Project.Action action = this.model.getAction();
    
    	// Then perform the desired updates depending on the action
    	switch( action ){
    		
    		
    	}
    }

    // Controller
    private class Controller implements ActionListener{
    	
    	private ProjectPanel view;
    	private Project model;
    	
    	/**
    	 * Constructor
    	 * @param view The view that is controlled
    	 */
    	public Controller( ProjectPanel view ){
    		this.view = view;
    		this.model = view.model;
    	}
    	
        @Override
		public void actionPerformed(ActionEvent e) {
	    	
	    	// Extract the command string
	    	String cmd = e.getActionCommand();

	    	// Do something :)
	    	
			
		}
    }

}


